





<script type="text/javascript">
$(document).ready(function(){
    $('#member_country').change(function(){ //any select change on the dropdown with id country trigger this code
        $("#member_state > option").remove(); //first of all clear select items
        var countryid = $('#member_country').val();  // here we are taking country id of the selected one.
        //alert(countryid)
        $("#member_state").removeAttr('disabled');
       
        var base_url = $('body').data('baseurl');
		//alert(base_url);
        $.ajax({
            type: "POST",
            url: base_url+"secure/location/location_management/get_regions/"+countryid, //here we are calling our user controller and get_cities method with the country_id
            
            success: function(regions) //we're calling the response json array 'cities'
            {
            	var opt1 = $('<option />'); // here we're creating a new select option with for each city
                opt1.val(0);
                opt1.text("--Select State--");
                $('#member_state').append(opt1); //here we will append these new select options to a dropdown with the id 'cities'
                
            	
                $.each(regions,function(id,statename) //here we're doing a foeach loop round each city with id as the key and city as the value
                {
                	var opt = $('<option />'); // here we're creating a new select option with for each city
                    opt.val(id);
                    opt.text(statename);
                    $('#member_state').append(opt); //here we will append these new select options to a dropdown with the id 'cities'
                });
            }

        });

    });
});

$(document).ready(function(){
    $('#member_state').change(function(){ //any select change on the dropdown with id country trigger this code
        $("#member_city > option").remove(); //first of all clear select items
        var stateid = $('#member_state').val();  // here we are taking country id of the selected one.
        //alert(state_id)
         $("#member_city").removeAttr('disabled');
       
        var base_url = $('body').data('baseurl');
		//alert(base_url);
        
        
        //var base_url = "<?php echo 'HELL'; ?>";
        //alert (base_url);
        
        
        $.ajax({
            type: "POST",
            url: base_url+"location/locations/get_cities/"+stateid, //here we are calling our user controller and get_cities method with the country_id
            
            success: function(cities) //we're calling the response json array 'cities'
            {
            	var opt1 = $('<option />'); // here we're creating a new select option with for each city
                opt1.val(0);
                opt1.text("--Select City--");
                $('#member_city').append(opt1); //here we will append these new select options to a dropdown with the id 'cities'
                
            	
                $.each(cities,function(id,city) //here we're doing a foeach loop round each city with id as the key and city as the value
                {
                	var opt = $('<option />'); // here we're creating a new select option with for each city
                    opt.val(id);
                    opt.text(city);
                    $('#member_city').append(opt); //here we will append these new select options to a dropdown with the id 'cities'
                });
            }

        });

    });
});
</script>
<?php 
if($mode== "ADD"){

	?>


<div class="heading-buttons">
	<h3 class="glyphicons picture">
		<i></i> Member Management
	</h3>
</div>
<div class="separator"></div>
<div class="widget widget-2 widget-body-white finances_summary">
	<div class="widget-head">
		<h4 class="heading glyphicons picture">
			<i></i> Add Member
		</h4>
		<span class="pull-right"> <a
			href="<?= base_url();?>secure/reports/member_report"> <span
				class="btn btn-inverse margin-right"> Go to Member List</span>
		</a>
		</span>
	</div>
	<div class="widget-body">
		<div class="row-fluid">
			<form name="banner" method="POST"
				action="<?= base_url();?>secure/reports/member_report/submit">
				<fieldset>
					<table class="table table-condensed">
						<tbody>
							<tr>
								<td colspan="3" class="table-no-broder"><?php
								$this->session->flashdata('message'); {
									$msg = $this->session->flashdata('message');
									echo '<font color="red">' . $msg . '</font>';
								}
								?>
								</td>
							</tr>
							<tr>


								<td class="left"><label>Select Type</label>
								</td>

								<td><select name="mem_type" style="width: 150px">
										<option value="" selected="selected">---Select Type---</option>


										<option value="NOR">NOR</option>

										<option value="RES">RES</option>

								</select>
								</td>
							</tr>

							<tr>

								<td class="left"><label>Title</label></td>
								<td><input name="title" type="text" size="40" /></td>
								<td></td>
							</tr>


							<tr>
								<td class="left"><label> Name</label></td>
								<td><input name="name" type="text" size="40" value="#" /></td>
								<td></td>
							</tr>

							<tr>
								<td class="left"><label> Phone</label></td>
								<td><input name="phone" type="text" size="40" value="#" /></td>
								<td></td>
							</tr>

							<tr>
								<td class="left"><label> Email</label></td>
								<td><input name="email" type="text" size="40" value="#" /></td>
								<td></td>
							</tr>

							<tr>


								<td class="left"><label>Location</label>
								</td>
								<td><select name="member_country" id="member_country">
										<option>-- Country --</option>
										<?php foreach($country as $country):?>
										<option value="<?= $country->id;?>">
											<?= $country->country;?>
										</option>
										<?php endforeach; ?>
								</select> <select name="member_state" id="member_state"
									style="width: 150px">
										<option value="" selected="selected">---Select State---</option>
								</select> <select name="member_city" id="member_city"
									style="width: 150px">
										<option value="" selected="selected">---Select City---</option>
								</select>
								</td>
							</tr>

							<tr>
								<td></td>
								<td><input type="checkbox" name="iagree">I Agree
							
							</tr>
							<tr>
								<td></td>
								<td><label> <input type="submit" class="btn small" name="add"
										value="Add Member" <?php if($this->config->item('mode')=='DEMO'){?>onclick="alert ('Sorry! Demo mode '); return false;" <?} else?>onclick="return confirm('Are you sure ?');" />
								</label>
								</td>
								<td></td>
							</tr>
					
					</table>
				</fieldset>
			</form>
		</div>
	</div>
</div>


<?php }?>
<?php 
if($mode=="EDIT"){
	?>

<div class="heading-buttons">
	<h3 class="glyphicons picture">
		<i></i> Member Management
	</h3>



</div>
<div class="separator"></div>




<div class="widget widget-2 widget-body-white finances_summary">
	<div class="widget-head">
		<h4 class="heading glyphicons picture">
			<i></i> Edit Member
		</h4>
		<span class="pull-right"> <a
			href="<?= base_url();?>secure/reports/member_report"> 
				<span class="btn btn-inverse margin-right"><i class="icon-list icon-white"></i> Member List </span>
		</a>
		</span>
	</div>
	<div class="widget-body">
		<div class="row-fluid">

			<form name="banner" method="POST"
				action="<?= base_url();?>secure/reports/member_report/update">

				<fieldset>
					<table class="table table-condensed">
						<tbody>
							<tr>
								<td colspan="3" class="table-no-broder"><?php
								$this->session->flashdata('message'); {
									$msg = $this->session->flashdata('message');
									echo '<font color="red">' . $msg . '</font>';
								}
								?>
								</td>
							</tr>
							<tr>


								<td class="left"><label>Select Type</label>
								</td>

								<td><select name="mem_type" style="width: 150px">
										<option value="<?= $member['details']->type;?>">
											<?= $member['details']->type;?>
										</option>


										

										<option value="RES">
											<?php if ($member['details']->type=="RES") echo 'selected="selected"';?>RES
										</option>

								</select>
								</td>
							</tr>

							<tr>

								<td class="left"><label>Title</label></td>
								<td><input name="title" type="text" size="40"
									value="<?= $member['details']->title;?>" /></td>
								<td></td>
							</tr>


							<tr>
								<td class="left"><label> Name</label></td>
								<td><input name="name" type="text" size="40"
									value="<?= $member['details']->name;?>" /></td>
								<td></td>
							</tr>

							<tr>
								<td class="left"><label> Phone</label></td>
								<td><input name="phone" type="text" size="40"
									value="<?= $member['details']->phone;?>" /></td>
								<td></td>
							</tr>

							<tr>
								<td class="left"><label> Email</label></td>
								<td><input name="email" type="text" size="40"
									value="<?= $member['details']->email;?>" /></td>
								<td></td>
							</tr>

							<tr>


								<td class="left"><label>Location</label>
								</td>

								<td><select name="member_country" id="member_country"
									style="width: 150px">
										<?php foreach($country as $country):?>
										<option value="<?= $country->id;?>"
										<?php if($country->id == $member['details']->country){echo "selected=selected";}?>>
											<?= $country->country;?>
										</option>
										<?php endforeach; ?>


								</select> <select name="member_state" id="member_state"
									style="width: 150px">
										<option>---Select State---</option>

										<?php foreach($state as $state):?>
										<option value="<?= $state->id;?>"
										<?php if($state->id == $member['details']->state){echo "selected=selected";}?>>
											<?= $state->statename;?>
										</option>
										<?php endforeach;?>
								</select> <select name="member_city" id="member_city" style="width: 150px">
										<option>---Select City---</option>

										<?php foreach($city as $city):?>
										<option value="<?= $city->id;?>"<?php if($city->id == $member['details']->city){echo "selected=selected";}?>" >
											<?= $city->cityname;?>
										</option>
										<?php endforeach;?>
								</select>
								</td>
							</tr>
							<tr>
								<td></td>
								<td><input type="checkbox" name="iagree">I Agree
							
							</tr>
							<tr>
								<td></td>
								<td><label> <input type="hidden" name="id" value="<?= $id;?>"> <input
										type="submit" class="btn btn-info" name="update" value="Update" <?php if($this->config->item('mode')=='DEMO'){?>onclick="alert ('Sorry! Demo mode '); return false;" <?} else?>onclick="return confirm('Are you sure ?');" />
								</label>
								</td>
								<td></td>
							</tr>
					
					</table>
				</fieldset>
			</form>
		</div>
	</div>
</div>
<?php }?>